package com.hanhy.Page;

import com.hanhy.util.ConfigUtil;
import com.hanhy.util.Locator;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.Reporter;

public class LoginPage extends BasePage {

    public LoginPage(WebDriver driver, String url) throws Exception {
        super(driver);
        this.open(url);
    }


    //用户名、密码、登录按钮元素定位
//	By userNameLocator = By.name("username");
//	By passWordLocator = By.name("password");
//	By submitBtnLocator = By.xpath("//div[@class='clearfix']/button");

    //定义locatorName
    String userNameLocator = "userNameInputBox";
    String passWordLocator = "passwordInputBox";
    String submitBtnLocator = "loginBtn";


    public void typeUserName(String value) throws Exception{
        type(userNameLocator,value);
    }
    public void typePassword(String value) throws Exception{
        type(passWordLocator,value);
    }

    public IndexPage login(String username, String password) throws Exception{
        typeUserName(username);
        log.info("type into username");
        typePassword(password);
        log.info("type into password");
        click(submitBtnLocator);
        return new IndexPage(driver);
    }


}
